<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="./vue.js"></script>
</head>

<body>

  <!-- 容器 -->
  <div id="app">

    <!-- 添加新名称 -->
    <div>
      <input v-model="uname" />
      <button @click="add">添加</button>
    </div>

    <ul>
      <li v-for="item in list" :key="item.id">
        <input type="checkbox"> 编号：{{item.id}} --- 姓名：{{item.name}}
      </li>
    </ul>
  </div>

  <script>
    const vm = new Vue({
      el: '#app',
      data: {
        uname: '',
        list: [
          { id: 0, name: '嬴政' },
          { id: 1, name: '吕不韦' },
          { id: 2, name: '嫪毐' }
        ]
      },
      methods: {
        add() {
          // 怼出一个新对象
          var newuser = { id: this.list.length, name: this.uname }
          this.list.unshift(newuser)
        }
      }
    })
  </script>

</body>

</html>